/*
 * Copyright 2010
 * Jairou Software Organization
 * All Rights Reserved.
 * 
 * This software is the proprietary 
 * information of Roger Ramia
 * and the Jairou Software Organization 
 * Use is subject to license terms.
 * 
 * For licensing information please visit
 * http://www.jairou.org/license
 * 
 * @author Roger Ramia
 */
package org.jairou.core;

/**
 * Basic String utilities
 * @author Roger Ramia
 */
public class Strings {
	
	/**
	 * sets the first letter
	 * of the given string to uppercase
	 * while leaving the rest alone
	 * @param in - original string
	 * @return string - resulting string
	 */
	public static String initUpper(String in) {
		String out = null;
		if (in != null) {
			out = in.substring(0,1).toUpperCase()+in.substring(1);
		}
		return out;
	}
	
	/**
	 * sets the first letter of the 
	 * @param in - original string
	 * @return - resulting string
	 */
	public static String initLower(String in) {
		String out = null;
		if (in != null) {
			out = in.substring(0,1).toLowerCase()+in.substring(1);
		}
		return out;
	}
	
	/**
	 * indicates if the provided string
	 * is null or empty when trimed  
	 * 
	 * @param in - original string
	 * @return boolean - true if the string is null or empty
	 */
	public static boolean nullOrEmpty(String in) {
		return (in == null || in.trim().equals(""));
	}	
	
	/**
	 * indicates if a string is ignorable whitespace
	 * @param input - string to check
	 * @return boolean - true is entire string is whitespace
	 */
	public static boolean isWhitespace(String input) {
		char[] chars = input.toCharArray();
		for (char c : chars) {
			if(!Character.isWhitespace(c))
				return false;
		}
		return true;
	}
}